/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 *
 * $Id: owndebug_example.cpp,v 1.3 2008-09-16 06:51:10 amaula Exp $
 *
 */

#include "owndebug.h"
#include <stdlib.h>
#include <time.h>

int main(void)
{
  // Initialize debug library
  debugInit();

  // Set the log file to use (if not set - nothing is saved to file)
  debugSetLogFilename("owndebug_example.log");

  // Set level to print (== displayed in screen while running)
  debugSetPrintLevel(2);

  // Set level to log (== saved in file)
  debugSetLogLevel(10);

  // Set format option to: full timestamp, full 'location' id.
  // (This is the default anyway, so this call is for example only)
  // See more options from the owndebug.h.
  debugSetMode(DEBUG_MODE_FORMAT_FILE_FUNC_LINE |
	       DEBUG_MODE_TIMESTAMP_HH_MM_SS_MS );
  

  // Print message, in level 2
  dPrint(2,"Hello, world!");

  // Print yet another, in level 3
  dPrint(3,"Hello, world! This message is only visible in the logfile");

  // Print informational message
  dPrint(1,"Now, switching debug format for example; no timestamp, only file+func");
  debugSetMode(DEBUG_MODE_FORMAT_FILE_FUNC);

  // Print one more to demonstrate on different format
  dPrint(2,"Hello world, now with little less header data :)");  
  dPrint(3,"Hello world, now with little less header data, and only visible in log.");

  dPrintLC(1, OWNDEBUG_COLOR_ATTR_BRIGHT, OWNDEBUG_COLOR_RED, OWNDEBUG_COLOR_BLACK, "Now some random colored lines :)");
  srandom(time(NULL));
  for(int i=0; i < 10; ++i) {
    unsigned char a = random() % 9;
    unsigned char f = random() % 8;
    unsigned char b = random() % 8;
    dPrintLC(1, a, f, b, "Hello world!");
  }

  
  // Now we're done.
  dPrint(1,"Done. Exiting program.");

  // Deinitialize debug library
  debugDeinit();
}

/******************************************************************************
 *
 * $Log: not supported by cvs2svn $
 * Revision 1.2  2008-09-15 13:03:29  amaula
 * Simple color support added. A little thread-unsafe, but who cares :)
 *
 * Revision 1.1  2007-03-05 13:06:03  amaula
 * Initial (and simple) example for owndebug library
 *
 *
 *****************************************************************************/
